package com.lanou.shunke.common.utils;

import com.lanou.shunke.common.entity.ShunkeResult;

public class ShunkeResultUtils {

    private static final int DEFAULT_SUCCESS_CODE = 200;
    private static final int DEFAULT_FAILURE_CODE = 500;

    public static ShunkeResult success(Object data) {
        ShunkeResult shunkeResult = new ShunkeResult();
        shunkeResult.setCode(DEFAULT_SUCCESS_CODE);
        shunkeResult.setMessage("success");
        shunkeResult.setData(data);
        return shunkeResult;
    }

    public static ShunkeResult error(int code) {
        ShunkeResult shunkeResult = new ShunkeResult();
        shunkeResult.setCode(code);
        shunkeResult.setMessage("failure");
        return shunkeResult;
    }

    public static ShunkeResult error() {
        ShunkeResult shunkeResult = new ShunkeResult();
        shunkeResult.setCode(DEFAULT_FAILURE_CODE);
        shunkeResult.setMessage("failure");
        return shunkeResult;
    }
}
